package com.aabte.auth.account.resource.api.group;

import com.aabte.commons.bean.BaseResponse;
import org.springframework.data.domain.Page;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import javax.validation.Valid;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;

@RequestMapping(path = "/v1/group", produces = MediaType.APPLICATION_JSON_VALUE)
public interface GroupApi {

    @RequestMapping(path = "/", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
    BaseResponse<String> create(@RequestBody @Valid CreateGroupCommand command);

    @RequestMapping(path = "/", method = RequestMethod.DELETE)
    BaseResponse<Boolean> delete(@RequestParam(name = "group_id") String groupId);

    @RequestMapping(path = "/", method = RequestMethod.GET)
    BaseResponse<Page<GroupDTO>> groups(
            @Min(1) @RequestParam(name = "page_number", defaultValue = "1") Integer pageNumber,
            @Min(10) @Max(1000) @RequestParam(name = "page_size", defaultValue = "10") Integer pageSize
    );

    @RequestMapping(path = "/account", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
    BaseResponse<Boolean> addAccount(@RequestBody @Valid AddAccountCommand command);

    @RequestMapping(path = "/role", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
    BaseResponse<Boolean> addRole(@RequestBody @Valid AddRoleCommand command);
}
